#include "chart_actor.h"

void Chart_Actor::paintChart(QPainter & p)
{
    QPen tmp = p.pen();
    p.setPen(paintChartDrawPen);

    int sx = paintStart.rx(),sy = paintStart.ry(),ex = paintEnd.rx(),ey = paintEnd.ry();

    int d = ex - sx; // 直径
    if(graphPath) delete graphPath;
    graphPath = new QPainterPath;
    graphPath->addEllipse(sx,sy,d,d); // 添加一个椭圆
    graphPath->moveTo(sx + (d / 2) ,sy + d);
    graphPath->lineTo(sx + (d / 2) ,2 * d);
    graphPath->moveTo(sx + (d / 2) - d / 2 ,sy + d + d / 5);
    graphPath->lineTo(sx + (d / 2) + d / 2 ,sy + d + d / 5);
    graphPath->moveTo(sx + (d / 2) ,2 * d);
    graphPath->lineTo(sx , 2 * d + 50);
    graphPath->moveTo(sx + (d / 2) ,2 * d);
    graphPath->lineTo(sx + d,2 * d + 50);

    p.fillPath(*graphPath,paintChartFillPen);
    p.drawPath(*graphPath);

    p.setPen(tmp);
}
